/**
 * 
 */
package com.sci.web.action.eninfomanager;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.ChangedInfoCompare;
import com.sci.web.bean.Enterprise_Base;
import com.sci.web.dao.EnterpriseInfoManageDao;

/**
 * @author BaiFuyou
 * @date: Oct 31, 2011 4:24:11 PM
 * 
 * 获取企业对比数据
 */
public class GetChangedInfoCompareAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6916612005549345018L;
	@Resource
	private EnterpriseInfoManageDao enterpriseInfoManageDao;
	private int id;

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		List<Enterprise_Base> frist = enterpriseInfoManageDao.getFristValue(id);
		List<Enterprise_Base> second = enterpriseInfoManageDao.getSecondValue(id);
		List<ChangedInfoCompare> changeinfo = new ArrayList<ChangedInfoCompare>();
		if (frist.size() == 1 && second.size() == 1) {
			Enterprise_Base f = frist.get(0);
			Enterprise_Base s = second.get(0);
			changeinfo = getChangedInfo(f, s);
		}
		super.outPrint(super.getJSONArrayString(changeinfo));
		return "json";
	}

	public List<ChangedInfoCompare> getChangedInfo(Enterprise_Base f, Enterprise_Base s) {
		List<ChangedInfoCompare> l = new ArrayList<ChangedInfoCompare>();
		if(f.getEnterprise_name().equals(s.getEnterprise_name())){
			l.add(new ChangedInfoCompare("企业名称",f.getEnterprise_name(),""));
		}else{
			l.add(new ChangedInfoCompare("企业名称","<STRIKE>"+f.getEnterprise_name()+"</STRIKE>",s.getEnterprise_name()));
		}
		if(f.getEnterprise_city() == s.getEnterprise_city()){
			l.add(new ChangedInfoCompare("企业所在市",getCityName(f.getEnterprise_city()),""));
		}else{
			l.add(new ChangedInfoCompare("企业所在市","<STRIKE>"+getCityName(f.getEnterprise_city())+"</STRIKE>",getCityName(s.getEnterprise_city())));
		}
		if(f.getEnterprise_address().equals(s.getEnterprise_address())){
			l.add(new ChangedInfoCompare("企业地址",f.getEnterprise_address(),""));
		}else{
			l.add(new ChangedInfoCompare("企业地址","<STRIKE>"+f.getEnterprise_address()+"</STRIKE>",s.getEnterprise_address()));
		}
		if(f.getEnterprise_postcode().equals(s.getEnterprise_postcode())){
			l.add(new ChangedInfoCompare("企业邮编",f.getEnterprise_postcode(),""));
		}else{
			l.add(new ChangedInfoCompare("企业邮编","<STRIKE>"+f.getEnterprise_postcode()+"</STRIKE>",s.getEnterprise_postcode()));
		}
		if(f.getEnterprise_corporate_code().equals(s.getEnterprise_corporate_code())){
			l.add(new ChangedInfoCompare("企业法人代码",f.getEnterprise_corporate_code(),""));
		}else{
			l.add(new ChangedInfoCompare("企业法人代码","<STRIKE>"+f.getEnterprise_corporate_code()+"</STRIKE>",s.getEnterprise_corporate_code()));
		}
		if(f.getEnterprise_corporateRepresentative().equals(s.getEnterprise_corporateRepresentative())){
			l.add(new ChangedInfoCompare("企业法人代表",f.getEnterprise_corporateRepresentative(),""));
		}else{
			l.add(new ChangedInfoCompare("企业法人代表","<STRIKE>"+f.getEnterprise_corporateRepresentative()+"</STRIKE>",s.getEnterprise_corporateRepresentative()));
		}
		if(f.getEnterprise_telephone().equals(s.getEnterprise_telephone())){
			l.add(new ChangedInfoCompare("联系电话",f.getEnterprise_telephone(),""));
		}else{
			l.add(new ChangedInfoCompare("联系电话","<STRIKE>"+f.getEnterprise_telephone()+"</STRIKE>",s.getEnterprise_telephone()));
		}
		if(f.getEnterprise_person_incharge().equals(s.getEnterprise_person_incharge())){
			l.add(new ChangedInfoCompare("企业负责人",f.getEnterprise_person_incharge(),""));
		}else{
			l.add(new ChangedInfoCompare("企业负责人","<STRIKE>"+f.getEnterprise_person_incharge()+"</STRIKE>",s.getEnterprise_person_incharge()));
		}
		if(f.getEnterprise_phone_incharge().equals(s.getEnterprise_phone_incharge())){
			l.add(new ChangedInfoCompare("负责人电话",f.getEnterprise_phone_incharge(),""));
		}else{
			l.add(new ChangedInfoCompare("负责人电话","<STRIKE>"+f.getEnterprise_phone_incharge()+"</STRIKE>",s.getEnterprise_phone_incharge()));
		}
		if(f.getEnterprise_eco_type() == s.getEnterprise_eco_type()){
			l.add(new ChangedInfoCompare("企业经济类型",getEnterprise_eco_typeName(f.getEnterprise_eco_type()),""));
		}else{
			l.add(new ChangedInfoCompare("企业经济类型","<STRIKE>"+getEnterprise_eco_typeName(f.getEnterprise_eco_type())+"</STRIKE>",getEnterprise_eco_typeName(s.getEnterprise_eco_type())));
		}
		if(f.getEnterprise_org_type() == s.getEnterprise_org_type()){
			l.add(new ChangedInfoCompare("企业组织类型",getEnterprise_org_typeName(f.getEnterprise_org_type()),""));
		}else{
			l.add(new ChangedInfoCompare("企业组织类型","<STRIKE>"+getEnterprise_org_typeName(f.getEnterprise_org_type())+"</STRIKE>",getEnterprise_org_typeName(s.getEnterprise_org_type())));
		}
		if(f.getEnterprise_largest_sharehoder().equals(s.getEnterprise_largest_sharehoder())){
			l.add(new ChangedInfoCompare("第一大股东名称",f.getEnterprise_largest_sharehoder(),""));
		}else{
			l.add(new ChangedInfoCompare("第一大股东名称","<STRIKE>"+f.getEnterprise_largest_sharehoder()+"</STRIKE>",s.getEnterprise_largest_sharehoder()));
		}
		if(f.getEnterprise_largest_share() == s.getEnterprise_largest_share()){
			l.add(new ChangedInfoCompare("第一大股东名称",f.getEnterprise_largest_share()+"",""));
		}else{
			l.add(new ChangedInfoCompare("第一大股东名称","<STRIKE>"+f.getEnterprise_largest_share()+""+"</STRIKE>",s.getEnterprise_largest_share()+""));
		}
		if(f.getEnterprise_listed_type() == s.getEnterprise_listed_type()){
			l.add(new ChangedInfoCompare("企业上市情况",getStockName(f.getEnterprise_listed_type()),""));
		}else{
			l.add(new ChangedInfoCompare("企业上市情况","<STRIKE>"+getStockName(f.getEnterprise_listed_type())+"</STRIKE>",getStockName(s.getEnterprise_listed_type())));
		}
		if(f.getEnterprise_science_type() == s.getEnterprise_science_type()){
			l.add(new ChangedInfoCompare("企业科技类别情况",getEnterprise_science_typeName(f.getEnterprise_science_type()),""));
		}else{
			l.add(new ChangedInfoCompare("企业科技类别情况","<STRIKE>"+getEnterprise_science_typeName(f.getEnterprise_science_type())+"</STRIKE>",getEnterprise_science_typeName(s.getEnterprise_science_type())));
		}
		if(f.getEnterprise_industry_code() == s.getEnterprise_industry_code()){
			l.add(new ChangedInfoCompare("企业所属类型情况",getProfessionName(f.getEnterprise_industry_code()),""));
		}else{
			l.add(new ChangedInfoCompare("企业所属类型情况","<STRIKE>"+getProfessionName(f.getEnterprise_industry_code())+"</STRIKE>",getProfessionName(s.getEnterprise_industry_code())));
		}
		if(f.getEnterprise_credit_degree() == s.getEnterprise_credit_degree()){
			l.add(new ChangedInfoCompare("企业信用等级",getGradeName(f.getEnterprise_credit_degree()),""));
		}else{
			l.add(new ChangedInfoCompare("企业信用等级","<STRIKE>"+getGradeName(f.getEnterprise_credit_degree())+"</STRIKE>",getGradeName(s.getEnterprise_credit_degree())));
		}
		if(f.getEnterprise_field_closeness() == s.getEnterprise_field_closeness()){
			l.add(new ChangedInfoCompare("企业劳动密集度",getEnterprise_field_closenessName(f.getEnterprise_field_closeness()),""));
		}else{
			l.add(new ChangedInfoCompare("企业劳动密集度","<STRIKE>"+getEnterprise_field_closenessName(f.getEnterprise_field_closeness())+"</STRIKE>",getEnterprise_field_closenessName(s.getEnterprise_field_closeness())));
		}
		if(f.getEnterprise_business_field().equals(s.getEnterprise_business_field())){
			l.add(new ChangedInfoCompare("企业经营范围",f.getEnterprise_business_field(),""));
		}else{
			l.add(new ChangedInfoCompare("企业经营范围","<STRIKE>"+f.getEnterprise_business_field()+"</STRIKE>",s.getEnterprise_business_field()));
		}
		if(f.getEnterprise_major_business().equals(s.getEnterprise_major_business())){
			l.add(new ChangedInfoCompare("企业主营业务",f.getEnterprise_major_business(),""));
		}else{
			l.add(new ChangedInfoCompare("企业主营业务","<STRIKE>"+f.getEnterprise_major_business()+"</STRIKE>",s.getEnterprise_major_business()));
		}
		if(f.getEnterprise_staff_count() == s.getEnterprise_staff_count()){
			l.add(new ChangedInfoCompare("企业职工总数",f.getEnterprise_staff_count()+"",""));
		}else{
			l.add(new ChangedInfoCompare("企业职工总数","<STRIKE>"+f.getEnterprise_staff_count()+""+"</STRIKE>",s.getEnterprise_staff_count()+""));
		}
		if(f.getEnterprise_staff_collegedegree_count() == s.getEnterprise_staff_collegedegree_count()){
			l.add(new ChangedInfoCompare("大专以上人数",f.getEnterprise_staff_collegedegree_count()+"",""));
		}else{
			l.add(new ChangedInfoCompare("大专以上人数","<STRIKE>"+f.getEnterprise_staff_collegedegree_count()+""+"</STRIKE>",s.getEnterprise_staff_collegedegree_count()+""));
		}
		if(f.getEnterprise_research_staff_count() == s.getEnterprise_research_staff_count()){
			l.add(new ChangedInfoCompare("研发人员总数",f.getEnterprise_research_staff_count()+"",""));
		}else{
			l.add(new ChangedInfoCompare("研发人员总数","<STRIKE>"+f.getEnterprise_research_staff_count()+""+"</STRIKE>",s.getEnterprise_research_staff_count()+""));
		}
		if(f.getEnterprise_senior_technician_count() == s.getEnterprise_senior_technician_count()){
			l.add(new ChangedInfoCompare("高级技工人员数",f.getEnterprise_senior_technician_count()+""+"</STRIKE>",""));
		}else{
			l.add(new ChangedInfoCompare("高级技工人员数","<STRIKE>"+f.getEnterprise_senior_technician_count()+"</STRIKE>",s.getEnterprise_senior_technician_count()+""));
		}
		return l;
	}

	public String getCityName(int code) {
		String name = "";
		if (code == 1) {
			name = "杭州市";
		} else if (code == 2) {
			name = "宁波市";
		} else if (code == 3) {
			name = "温州市";
		} else if (code == 4) {
			name = "绍兴市";
		} else if (code == 5) {
			name = "嘉兴市";
		} else if (code == 5) {
			name = "湖州市";
		} else if (code == 7) {
			name = "金华市";
		} else if (code == 8) {
			name = "台州市";
		} else if (code == 9) {
			name = "舟山市";
		} else if (code == 10) {
			name = "丽水市";
		} else if (code == 11) {
			name = "衢州市";
		} else if (code == 12) {
			name = "义乌市";
		} else if (code == 13) {
			name = "省属企业";
		}
		return name;
	}

	public String getStockName(int code) {
		String name = "";
		if (code == 1) {
			name = "上海主板";
		} else if (code == 2) {
			name = "深圳中小板";
		} else if (code == 3) {
			name = "深圳创业板";
		} else if (code == 4) {
			name = "境外上市";
		} else if (code == 5) {
			name = "浙江省未上市公司股份转让平台";
		} else if (code == 6) {
			name = "尚未上市";
		}
		return name;
	}

	public String getProfessionName(int code) {
		String name = "";
		if (code == 1) {
			name = "装备制造业";
		} else if (code == 2) {
			name = "汽车行业";
		} else if (code == 3) {
			name = "船舶制造业";
		} else if (code == 4) {
			name = "医药行业";
		} else if (code == 5) {
			name = "钢铁行业";
		} else if (code == 6) {
			name = "电子信息行业";
		} else if (code == 7) {
			name = "石化行业";
		} else if (code == 8) {
			name = "纺织产业";
		} else if (code == 9) {
			name = "轻工食品行业";
		} else if (code == 10) {
			name = "有色金属行业";
		} else if (code == 11) {
			name = "建材行业";
		} else if (code == 12) {
			name = "光伏等新能源行业";
		}
		return name;
	}

	public String getGradeName(int code) {
		String name = "";
		if (code == 1) {
			name = "AAA";
		} else if (code == 2) {
			name = "AA";
		} else if (code == 3) {
			name = "B";
		} else if (code == 4) {
			name = "C";
		} else if (code == 5) {
			name = "无";
		}
		return name;
	}

	public String getEnterprise_eco_typeName(int code) {
		String name = "";
		if (code == 1) {
			name = "国有企业";
		} else if (code == 2) {
			name = "集体企业";
		} else if (code == 3) {
			name = "私营企业";
		}
		return name;
	}

	public String getEnterprise_org_typeName(int code) {
		String name = "";
		if (code == 1) {
			name = "有限责任公司";
		} else if (code == 2) {
			name = "股份有限公司";
		} else if (code == 3) {
			name = "股份合作企业";
		} else if (code == 4) {
			name = "其他企业";
		}
		return name;
	}

	public String getEnterprise_science_typeName(int code) {
		String name = "";
		if (code == 1) {
			name = "高新技术企业";
		} else if (code == 2) {
			name = "科技型中小企业";
		} else if (code == 3) {
			name = "民营科技企业";
		}
		return name;
	}

	public String getEnterprise_field_closenessName(int code) {
		String name = "";
		if (code == 1) {
			name = "高技术密集度";
		} else if (code == 2) {
			name = "中高技术密集度";
		} else if (code == 3) {
			name = "中低技术密集度";
		} else if (code == 4) {
			name = "低技术密集度";
		}
		return name;
	}
}
